<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        const p1 = new Promise((resolve, reject) => {
            console.log('开始请求A。。。');
            // throw new Error('网络异常。。。')
            try {
                setTimeout(() => {
                    console.log('A数据请求成功');
                    resolve({
                        token: 'ababab'
                    })
                }, 2000)
            } catch (e) {
                reject(e.message)

            }
        })

        
        const p2 = p1.then((value) => {
            console.log('成功');

            const re = new Promise((resolve, reject) => {
                console.log('开始请求B数据..');
               
                try {
                    throw new Error('B错误')
                    setTimeout(() => {
                        console.log('B数据请求成功');
                        resolve('okkk')

                    }, 2000)
                } catch (e) {
                    reject(e.message)

                }
            })
            return re
        })
        console.log('p2', p2);

    </script>
</body>

</html>